package com.foreveross.dao.imp;

import java.util.List;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.stereotype.Repository;

import com.foreveross.common.SQLUtil;
import com.foreveross.dao.LogDAO;
import com.foreveross.vo.Log;
import com.foreveross.vo.SysUser;
@Repository("logDAO")
public class LogDAOImp extends SQLUtil implements LogDAO {
	 

	@Override
	public List<Log> findLogList(String type, String creater, int pageIndex,
			int pageSize) throws Exception {
		StringBuffer queryString = new StringBuffer(
				"select model from Log model where 1=1 ");
		if (!"".equals(type) && null != type) {
			queryString.append(" and model.type=" + type);
		}
		if (!"".equals(creater) && null != creater) {
			queryString.append(" and model.creater like '%" + creater + "%'");
		}
		queryString.append(" order by model.createTime desc");
		return (List<Log>) findObjectAll(queryString.toString(), pageIndex,
				pageSize);
	}
	
	
	@Override
	public long findLogListCount(String type, String creater)
			throws Exception {
		StringBuffer queryString = new StringBuffer("select count(*) from Log model where 1=1 ");
		if(!"".equals(type) && null != type){
			queryString.append(" and model.type="+type);
		}
		if(!"".equals(creater) && null != creater){
			queryString.append(" and model.creater like '%"+creater+"%'");
		}
		return (Long)findObjectAll(queryString.toString()).get(0);
	}



}
